import request from '@/utils/request.js'

const prevUrl = '/apply/';
const code = 'ZCGH';

export default {
  // 查询列表
  list: function(query, pageReq) {
    return request({
      url:  `${prevUrl}list/${code}`,
      method: 'post',
      data: query,
      params: pageReq
    })
  },
  // 查询详情
  detail: function(row) {
    return request({
      url: prevUrl+row.id,
      method: 'get'
    })
  },
  // 保存申请
  save: function(actionType, { apply, items, itemsDel }) {

    return request({
      url: `${prevUrl}save/${code}`,
      method: 'post',
      data: {
        actionType: actionType,
        apply: apply,
        items: items,
        itemsDel
      }
    })
  },
  // 提交申请
  sub: function(id) {
    return request({
      url: prevUrl+'sub/'+id,
      method: 'post'
    })
  },
  // 保存并提交申请
  saveAndSub: function(actionType, { apply, items, itemsDel }) {
    return request({
      url: prevUrl+`saveAndSub/${code}`,
      method: 'post',
      data: {
        actionType: actionType,
        apply: apply,
        items: items,
        itemsDel
      }
    })
  },

  del: function (id) {
    return request({
      url: prevUrl+id,
      method: 'delete'
    })
  }
}

